package cn.ztelovecly.springboot.framework.base;

import java.io.Serializable;

@Deprecated
public class BaseSO implements Serializable {

    private static final long serialVersionUID = 1L;

	// 搜索文本
	private String searchText;
	// 页索引
	private int pageIndex = 1;
	// 页大小
	private int pageSize = 10;

	//-----------getter&&setter-------------
	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	/**
	 * 获取页索引。如果当前索引小于1，则回1.
	 * @return
	 */
	public int getPageIndex() {
		if (this.pageIndex <= 0) {
			return 1;
		}
		return this.pageIndex;
	}

	public void setPageIndex(int pageIndex) {
		this.pageIndex = pageIndex;
	}

	public String getSearchText() {
		return searchText;
	}

	public void setSearchText(String searchText) {
		this.searchText = searchText;
	}

	/**
	 * 获得当前分页第一项的index
	 * @return
	 */
	public int getBeginItemIndex() {
		return ((this.getPageIndex() - 1) * this.getPageSize());
	}

	/**
	 * 获得当前分页最后一项的index
	 * @return
	 */
	public int getEndItemIndex() {
		return this.getPageIndex() * this.getPageSize() - 1;
	}

}
